//
//  ByteBufferWriter.m
//  ByteBuf
//
//  Created by 周最新 on 15/8/29.
//  Copyright (c) 2015年 zzx. All rights reserved.
//

#import "ByteBufferWriter.h"

@implementation ByteBufferWriter

- (instancetype)init
{
    if (self = [super init]) {
        _data = [NSMutableData data];
    }
    return self;
}

- (void)writeByte:(char)byte
{
    [_data appendBytes:(const char *)&byte length:sizeof(char)];
}

- (void)writeBytes:(NSData *)bytes
{
    if (bytes.length) [_data appendData:bytes];
}

- (void)writeUInt16:(uint16_t)value
{
    [_data appendBytes:(const char *)&value length:sizeof(uint16_t)];
}

- (void)writeUInt32:(uint32_t)value
{
    [_data appendBytes:(const char *)&value length:sizeof(uint32_t)];
}


@end
